package cn.edu.swu.mysqlite

import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import android.nfc.Tag
import android.util.Log
import android.widget.Toast

class MyDatabaseHelperTodo(val context: Context, name: String, version: Int) :
    SQLiteOpenHelper(context, name, null, version) {
    private val createTodo = "create table Todo (" +
            " id integer primary key autoincrement," +
            " name text," +
            "record text)"

    override fun onCreate(db: SQLiteDatabase) {
        db.execSQL(createTodo)
        Toast.makeText(context, "Create succeeded", Toast.LENGTH_SHORT).show()
    }
    override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
        db.execSQL("drop table if exists Todo")
        Log.d(".Todo","drop old")
        onCreate(db)

    }

}